/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Controller;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author gulben
 */
@Entity
@Table(name = "CITYS")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Citys.findAll", query = "SELECT c FROM Citys c"),
    @NamedQuery(name = "Citys.findById", query = "SELECT c FROM Citys c WHERE c.id = :id"),
    @NamedQuery(name = "Citys.findByCitycode", query = "SELECT c FROM Citys c WHERE c.citycode = :citycode"),
    @NamedQuery(name = "Citys.findByCityname", query = "SELECT c FROM Citys c WHERE c.cityname = :cityname"),
    @NamedQuery(name = "Citys.findByDistrict", query = "SELECT c FROM Citys c WHERE c.district = :district")})
public class Citys implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Column(name = "CITYCODE")
    private int citycode;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 40)
    @Column(name = "CITYNAME")
    private String cityname;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 100)
    @Column(name = "DISTRICT")
    private String district;
    @OneToMany(mappedBy = "cityid")
    private Collection<Customer> customerCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "cityid")
    private Collection<County> countyCollection;

    public Citys() {
    }

    public Citys(Integer id) {
        this.id = id;
    }

    public Citys(Integer id, int citycode, String cityname, String district) {
        this.id = id;
        this.citycode = citycode;
        this.cityname = cityname;
        this.district = district;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public int getCitycode() {
        return citycode;
    }

    public void setCitycode(int citycode) {
        this.citycode = citycode;
    }

    public String getCityname() {
        return cityname;
    }

    public void setCityname(String cityname) {
        this.cityname = cityname;
    }

    public String getDistrict() {
        return district;
    }

    public void setDistrict(String district) {
        this.district = district;
    }

    @XmlTransient
    public Collection<Customer> getCustomerCollection() {
        return customerCollection;
    }

    public void setCustomerCollection(Collection<Customer> customerCollection) {
        this.customerCollection = customerCollection;
    }

    @XmlTransient
    public Collection<County> getCountyCollection() {
        return countyCollection;
    }

    public void setCountyCollection(Collection<County> countyCollection) {
        this.countyCollection = countyCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Citys)) {
            return false;
        }
        Citys other = (Citys) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Controller.Citys[ id=" + id + " ]";
    }
    
}
